#ifndef __BSP_ZB_H__
#define __BSP_ZB_H__


#include "config.h"
//#include <stdint.h>
#include "hc32_ddl.h"


/** @defgroup ZB_IO definition
 * @{
 */
#define BSP_ZB_SET_PORT     (PortA)     /* OUTPUT */
#define BSP_ZB_SET_PIN      (Pin04)
#define BSP_ZB_RST_PORT     (PortA)     /* OUTPUT */
#define BSP_ZB_RST_PIN      (Pin02)
#define BSP_ZB_EVEN_PORT    (PortA)     /* OUTPUT */
#define BSP_ZB_EVEN_PIN     (Pin01)


#define BSP_ZB_STA_PORT     (PortA)     /* INPUT */
#define BSP_ZB_STA_PIN      (Pin03)



#define ZbSetLow()       (PORT_ResetBits(BSP_ZB_SET_PORT,BSP_ZB_SET_PIN))
#define ZbSetHigh()      (PORT_SetBits(BSP_ZB_SET_PORT,BSP_ZB_SET_PIN))
#define ZbRstLow()       (PORT_ResetBits(BSP_ZB_RST_PORT,BSP_ZB_RST_PIN))
#define ZbRstHigh()      (PORT_SetBits(BSP_ZB_RST_PORT,BSP_ZB_RST_PIN))
#define ZbEvenLow()      (PORT_ResetBits(BSP_ZB_EVEN_PORT,BSP_ZB_EVEN_PIN))
#define ZbEvenHigh()     (PORT_SetBits(BSP_ZB_EVEN_PORT,BSP_ZB_EVEN_PIN))


#define ZbStaInLow()      (PORT_GetBit(BSP_ZB_STA_PORT,BSP_ZB_STA_PIN) == Reset)



/**
 * @}
 */


/** @defgroup ZB_IO definition
 * @{
 */
/* USART channel definition */
#define BSP_ZB_USART_CH                         (M4_USART2)
#define BSP_ZB_USART_CLK                        (PWC_FCG1_PERIPH_USART2)

/* USART baudrate definition */
#define BSP_ZB_USART_BAUDRATE                   (9600ul)

/* USART RX Port/Pin definition */
#define BSP_ZB_USART_RX_PORT                    (PortA)  
#define BSP_ZB_USART_RX_PIN                     (Pin06)          
#define BSP_ZB_USART_RX_FUNC                    (Func_Usart2_Rx)

/* USART TX Port/Pin definition */
#define BSP_ZB_USART_TX_PORT                    (PortA)  
#define BSP_ZB_USART_TX_PIN                     (Pin05)          
#define BSP_ZB_USART_TX_FUNC                    (Func_Usart2_Tx)

/* USART interrupt number  */
#define BSP_ZB_USART_EI_NUM                     (INT_USART2_EI)
#define BSP_ZB_USART_RI_NUM                     (INT_USART2_RI)
#define BSP_ZB_USART_TI_NUM                     (INT_USART2_TI)
#define BSP_ZB_USART_TCI_NUM                    (INT_USART2_TCI)
/**
 * @}
 */



void BspZbInit(void);
void BspZbUartSet(uint8 type);



#endif

